﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.Data.Extensions;
using ModernChannel.Configuration;
using ModernChannel.Model.Model;

namespace ModernChannel.Data.DBConfig
{
    public class ProvinceConfiguration : DBConfig<Province>
    {
        public ProvinceConfiguration()
            : base(SystemConfiguration.Schema, SystemConfiguration.NamingType, SystemConfiguration.TABLE_PREFIX)
        {
            HasKey(k => k.Id);
            Property(x => x.Id).IsRequired();
            Property(c => c.Name).HasMaxLength(50).IsRequired();

            HasOptional(p => p.Region).WithMany(r => r.Provinces).HasForeignKey(k => k.RegionId);
        }
    }
}
